<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            outline: 0;
        }
        
        a {
            text-decoration: none;
            color: inherit;
        }
        
        .yx_tabbar {
            display: flex;
        }
        
        .yx_tabbar__item {
            flex: 1;
        }
        
        .yx_tabbar__item a {
            display: block;
            line-height: 50px;
            text-align: center;
        }
        
        .yx_tabbar__item a:first-child {
            border: 1px solid #ddd
        }
        
        .yx_tabbar__item_on {
            background-color: pink;
            color: white;
        }
    </style>
</head>

<body>
    <div class="yx_tabbar">
        <div class="yx_tabbar__item yx_tabbar__item_on">
            <a href="#" data-type="basic">basic</a>
        </div>
        <div class="yx_tabbar__item">
            <a href="#" data-type="super">super</a>
        </div>
    </div>
    <div id="list">

    </div>
    <script>
        const list = document.getElementById('list');
        const links = document.querySelectorAll('.yx_tabbar__item a');
        // const tabTypes = {
        //     basic: Symbol(),
        //     /*es6 里新的简单数据类型，独一无二*/
        //     super: Symbol()
        // }
        const tabTypes = {
            'basic': 'basic',
            'super': 'super'

        }
        links.forEach(link => {
            link.addEventListener('click', function(event) {
                event.preventDefault();
                // console.log(event);
                const type = event.target.dataset.type;
                const parent = this.parnetNode;
                if (!parent.classList.contains('yx_tabbar__item_on')) {
                    document.querySelector('.yx_tabbar__item_on').classList.remove('yx_tabbar__item_on');
                    parent.classList.add('yx_tabbar__item_on');
                }
                // console.log(type);
                // if (type == 'basic') {
                if (type == tabTypes.basic) {
                    list.innerText = 'basic'
                }
                // if (type == 'super') {
                if (type == tabTypes.super) {
                    list.innerText = 'super'
                }
            });
        });
    </script>
</body>

</html>